Optimal. Leaf size=70 \[ \frac {a x}{b^2}-\frac {2 \sqrt {a^2-b^2} \tan ^{-1}\left (\frac {b+a \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a^2-b^2}}\right )}{b^2 d}+\frac {\cos (c+d x)}{b d} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.08, antiderivative size = 70, normalized size of antiderivative = 1.00, number of steps
used = 5, number of rules used = 5, integrand size = 21, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.238, Rules used = {2774, 2814,
2739, 632, 210} \begin {gather*} -\frac {2 \sqrt {a^2-b^2} \text {ArcTan}\left (\frac {a \tan \left (\frac {1}{2} (c+d x)\right )+b}{\sqrt {a^2-b^2}}\right )}{b^2 d}+\frac {a x}{b^2}+\frac {\cos (c+d x)}{b d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 210
Rule 632
Rule 2739
Rule 2774
Rule 2814
Rubi steps
\begin {align*} \int \frac {\cos ^2(c+d x)}{a+b \sin (c+d x)} \, dx &=\frac {\cos (c+d x)}{b d}+\frac {\int \frac {b+a \sin (c+d x)}{a+b \sin (c+d x)} \, dx}{b}\\ &=\frac {a x}{b^2}+\frac {\cos (c+d x)}{b d}-\frac {\left (a^2-b^2\right ) \int \frac {1}{a+b \sin (c+d x)} \, dx}{b^2}\\ &=\frac {a x}{b^2}+\frac {\cos (c+d x)}{b d}-\frac {\left (2 \left (a^2-b^2\right )\right ) \text {Subst}\left (\int \frac {1}{a+2 b x+a x^2} \, dx,x,\tan \left (\frac {1}{2} (c+d x)\right )\right )}{b^2 d}\\ &=\frac {a x}{b^2}+\frac {\cos (c+d x)}{b d}+\frac {\left (4 \left (a^2-b^2\right )\right ) \text {Subst}\left (\int \frac {1}{-4 \left (a^2-b^2\right )-x^2} \, dx,x,2 b+2 a \tan \left (\frac {1}{2} (c+d x)\right )\right )}{b^2 d}\\ &=\frac {a x}{b^2}-\frac {2 \sqrt {a^2-b^2} \tan ^{-1}\left (\frac {b+a \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a^2-b^2}}\right )}{b^2 d}+\frac {\cos (c+d x)}{b d}\\ \end {align*}
________________________________________________________________________________________
Mathematica [B] Leaf count is larger than twice the leaf count of optimal. \(361\) vs. \(2(70)=140\).
time = 0.91, size = 361, normalized size = 5.16 \begin {gather*} \frac {\cos (c+d x) \left (2 (a-b) \tanh ^{-1}\left (\frac {\sqrt {a-b} \sqrt {-\frac {b (1+\sin (c+d x))}{a-b}}}{\sqrt {a+b} \sqrt {-\frac {b (-1+\sin (c+d x))}{a+b}}}\right ) \sqrt {1-\sin (c+d x)}+\sqrt {a+b} \left (-2 \sqrt {a-b} \tanh ^{-1}\left (\frac {\sqrt {\frac {b (1+\sin (c+d x))}{-a+b}}}{\sqrt {-\frac {b (-1+\sin (c+d x))}{a+b}}}\right ) \sqrt {1-\sin (c+d x)}+\sqrt {-\frac {b (-1+\sin (c+d x))}{a+b}} \left (2 \sqrt {b} \sinh ^{-1}\left (\frac {\sqrt {a-b} \sqrt {-\frac {b (1+\sin (c+d x))}{a-b}}}{\sqrt {2} \sqrt {b}}\right )+\sqrt {a-b} \sqrt {1-\sin (c+d x)} \sqrt {\frac {b (1+\sin (c+d x))}{-a+b}}\right )\right )\right )}{\sqrt {a-b} b \sqrt {a+b} d \sqrt {1-\sin (c+d x)} \sqrt {-\frac {b (-1+\sin (c+d x))}{a+b}} \sqrt {-\frac {b (1+\sin (c+d x))}{a-b}}} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.12, size = 96, normalized size = 1.37
method | result | size |
derivativedivides | \(\frac {\frac {2 \left (-a^{2}+b^{2}\right ) \arctan \left (\frac {2 a \tan \left (\frac {d x}{2}+\frac {c}{2}\right )+2 b}{2 \sqrt {a^{2}-b^{2}}}\right )}{b^{2} \sqrt {a^{2}-b^{2}}}+\frac {\frac {2 b}{1+\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )}+2 a \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{b^{2}}}{d}\) | \(96\) |
default | \(\frac {\frac {2 \left (-a^{2}+b^{2}\right ) \arctan \left (\frac {2 a \tan \left (\frac {d x}{2}+\frac {c}{2}\right )+2 b}{2 \sqrt {a^{2}-b^{2}}}\right )}{b^{2} \sqrt {a^{2}-b^{2}}}+\frac {\frac {2 b}{1+\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )}+2 a \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{b^{2}}}{d}\) | \(96\) |
risch | \(\frac {a x}{b^{2}}+\frac {{\mathrm e}^{i \left (d x +c \right )}}{2 b d}+\frac {{\mathrm e}^{-i \left (d x +c \right )}}{2 b d}+\frac {\sqrt {-a^{2}+b^{2}}\, \ln \left ({\mathrm e}^{i \left (d x +c \right )}-\frac {-i a +\sqrt {-a^{2}+b^{2}}}{b}\right )}{d \,b^{2}}-\frac {\sqrt {-a^{2}+b^{2}}\, \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a +\sqrt {-a^{2}+b^{2}}}{b}\right )}{d \,b^{2}}\) | \(142\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 0.36, size = 214, normalized size = 3.06 \begin {gather*} \left [\frac {2 \, a d x + 2 \, b \cos \left (d x + c\right ) + \sqrt {-a^{2} + b^{2}} \log \left (\frac {{\left (2 \, a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} - 2 \, a b \sin \left (d x + c\right ) - a^{2} - b^{2} + 2 \, {\left (a \cos \left (d x + c\right ) \sin \left (d x + c\right ) + b \cos \left (d x + c\right )\right )} \sqrt {-a^{2} + b^{2}}}{b^{2} \cos \left (d x + c\right )^{2} - 2 \, a b \sin \left (d x + c\right ) - a^{2} - b^{2}}\right )}{2 \, b^{2} d}, \frac {a d x + b \cos \left (d x + c\right ) + \sqrt {a^{2} - b^{2}} \arctan \left (-\frac {a \sin \left (d x + c\right ) + b}{\sqrt {a^{2} - b^{2}} \cos \left (d x + c\right )}\right )}{b^{2} d}\right ] \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [B] Leaf count of result is larger than twice the leaf count of optimal. 1923 vs.
\(2 (58) = 116\).
time = 173.13, size = 1923, normalized size = 27.47 \begin {gather*} \text {Too large to display} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A]
time = 5.33, size = 95, normalized size = 1.36 \begin {gather*} \frac {\frac {{\left (d x + c\right )} a}{b^{2}} - \frac {2 \, {\left (\pi \left \lfloor \frac {d x + c}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (a\right ) + \arctan \left (\frac {a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + b}{\sqrt {a^{2} - b^{2}}}\right )\right )} \sqrt {a^{2} - b^{2}}}{b^{2}} + \frac {2}{{\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 1\right )} b}}{d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 3.92, size = 318, normalized size = 4.54 \begin {gather*} \frac {2}{b\,d\,\left ({\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2+1\right )}+\frac {2\,a\,\mathrm {atan}\left (\frac {64\,a^2\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{64\,a^2-\frac {64\,a^4}{b^2}}+\frac {64\,a^4\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{64\,a^4-64\,a^2\,b^2}\right )}{b^2\,d}+\frac {2\,\mathrm {atanh}\left (\frac {64\,a^2\,\sqrt {b^2-a^2}}{64\,a^2\,b-\frac {64\,a^4}{b}-128\,a^3\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )+128\,a\,b^2\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}+\frac {128\,a\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {b^2-a^2}}{64\,a^2-\frac {64\,a^4}{b^2}-\frac {128\,a^3\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{b}+128\,a\,b\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}+\frac {64\,a^3\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {b^2-a^2}}{64\,a^4+128\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,a^3\,b-64\,a^2\,b^2-128\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,a\,b^3}\right )\,\sqrt {b^2-a^2}}{b^2\,d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________